home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 3 / Cream of the Crop 3.iso / comm / wnos5src.zip / ICMP.H < prev    next >
Text File  |  1993-08-09  |  5KB  |  154 lines

  1. #ifndef    _ICMP_H
  2. #define    _ICMP_H
  3.  
  4. #ifndef    _GLOBAL_H
  5. #include "global.h"
  6. #endif
  7.  
  8. #ifndef    _MBUF_H
  9. #include "mbuf.h"
  10. #endif
  11.  
  12. #ifndef    _IFACE_H
  13. #include "iface.h"
  14. #endif
  15.  
  16. #ifndef    _INTERNET_H
  17. #include "internet.h"
  18. #endif
  19.  
  20. #ifndef _IP_H
  21. #include "ip.h"
  22. #endif
  23.  
  24. #ifndef _SESSION_H
  25. #include "session.h"
  26. #endif
  27.  
  28. /* SNMP MIB variables, used for statistics and control. See RFC 1066 */
  29. extern struct mib_entry         Icmp_mib[];
  30. #define    icmpInMsgs                Icmp_mib[1].value.integer
  31. #define    icmpInErrors            Icmp_mib[2].value.integer
  32. #define icmpInDestUnreachs        Icmp_mib[3].value.integer
  33. #define icmpInTimeExcds            Icmp_mib[4].value.integer
  34. #define icmpInParmProbs            Icmp_mib[5].value.integer
  35. #define icmpInSrcQuenchs        Icmp_mib[6].value.integer
  36. #define icmpInRedirects            Icmp_mib[7].value.integer
  37. #define icmpInEchos                Icmp_mib[8].value.integer
  38. #define icmpInEchoReps            Icmp_mib[9].value.integer
  39. #define icmpInTimestamps        Icmp_mib[10].value.integer
  40. #define icmpInTimestampReps        Icmp_mib[11].value.integer
  41. #define icmpInAddrMasks            Icmp_mib[12].value.integer
  42. #define icmpInAddrMaskReps        Icmp_mib[13].value.integer
  43. #define icmpOutMsgs                Icmp_mib[14].value.integer
  44. #define icmpOutErrors            Icmp_mib[15].value.integer
  45. #define icmpOutDestUnreachs        Icmp_mib[16].value.integer
  46. #define icmpOutTimeExcds        Icmp_mib[17].value.integer
  47. #define icmpOutParmProbs        Icmp_mib[18].value.integer
  48. #define icmpOutSrcQuenchs        Icmp_mib[19].value.integer
  49. #define icmpOutRedirects        Icmp_mib[20].value.integer
  50. #define icmpOutEchos            Icmp_mib[21].value.integer
  51. #define icmpOutEchoReps            Icmp_mib[22].value.integer
  52. #define icmpOutTimestamps        Icmp_mib[23].value.integer
  53. #define icmpOutTimestampReps    Icmp_mib[24].value.integer
  54. #define icmpOutAddrMasks        Icmp_mib[25].value.integer
  55. #define icmpOutAddrMaskReps        Icmp_mib[26].value.integer
  56. #define    NUMICMPMIB    26
  57.  
  58. /* Internet Control Message Protocol */
  59.  
  60. /* Message types */
  61. #define    ICMP_ECHO_REPLY            0    /* Echo Reply */
  62. #define    ICMP_DEST_UNREACH        3    /* Destination Unreachable */
  63. #define    ICMP_QUENCH                4    /* Source Quench */
  64. #define    ICMP_REDIRECT            5    /* Redirect */
  65. #define    ICMP_ECHO                8    /* Echo Request */
  66. #define    ICMP_TIME_EXCEED        11    /* Time-to-live Exceeded */
  67. #define    ICMP_PARAM_PROB            12    /* Parameter Problem */
  68. #define    ICMP_TIMESTAMP            13    /* Timestamp */
  69. #define    ICMP_TIME_REPLY            14    /* Timestamp Reply */
  70. #define    ICMP_INFO_RQST            15    /* Information Request */
  71. #define    ICMP_INFO_REPLY            16    /* Information Reply */
  72. #define    ICMP_ADDR_MASK            17    /* Address mask request */
  73. #define    ICMP_ADDR_MASK_REPLY    18    /* Address mask reply */
  74. #define    ICMP_TYPES                19
  75.  
  76. /* Internal format of an ICMP header (checksum is missing) */
  77. struct icmp {
  78.     char type;
  79.     char code;
  80.      union icmp_args {
  81.         int16 mtu;
  82.         int32 unused;
  83.         unsigned char pointer;
  84.         int32 address;
  85.         struct {
  86.             int16 id;
  87.             int16 seq;
  88.         } echo;
  89.     } args;
  90. };
  91. #define    ICMPLEN        8    /* Length of ICMP header on the net */
  92. #define    NULLICMP    (union icmp_args *)0
  93.  
  94. /* Destination Unreachable codes */
  95. #define    ICMP_NET_UNREACH    0    /* Net unreachable */
  96. #define    ICMP_HOST_UNREACH    1    /* Host unreachable */
  97. #define    ICMP_PROT_UNREACH    2    /* Protocol unreachable */
  98. #define    ICMP_PORT_UNREACH    3    /* Port unreachable */
  99. #define    ICMP_FRAG_NEEDED    4    /* Fragmentation needed and DF set */
  100. #define    ICMP_ROUTE_FAIL        5    /* Source route failed */
  101.  
  102. #define    NUNREACH    6
  103.  
  104. /* Time Exceeded codes */
  105. #define    ICMP_TTL_EXCEED        0    /* Time-to-live exceeded */
  106. #define    ICMP_FRAG_EXCEED    1    /* Fragment reassembly time exceeded */
  107.  
  108. #define    NEXCEED        2
  109.  
  110. /* Redirect message codes */
  111. #define    ICMP_REDR_NET    0    /* Redirect for the network */
  112. #define    ICMP_REDR_HOST    1    /* Redirect for the host */
  113. #define    ICMP_REDR_TOS    2    /* Redirect for Type of Service, or-ed with prev */
  114.  
  115. #define    NREDIRECT    3
  116.  
  117. extern int Icmp_trace;
  118.  
  119. struct ping {
  120.     struct session *sp;
  121.     int32 target;        /* Starting target IP address */
  122.     int incflag;        /* If true, increment target after each ping */
  123.     int32 sent;        /* Total number of pings sent */
  124.     int32 srtt;        /* Smoothed round trip time */
  125.     int32 mdev;        /* Mean deviation */
  126.     int32 responses;    /* Total number of responses */
  127.     int32 interval;        /* Inter-ping interval, ticks */
  128.     int16 len;        /* Length of data portion of ping */
  129. };
  130. /* ICMP messages, decoded */
  131. extern char *Icmptypes[],*Unreach[],*Exceed[],*Redirect[];
  132.  
  133. struct icmplink {
  134.     char proto;
  135.     void (*funct) __ARGS((int32,int32,int32,char,char,struct mbuf **));
  136. };
  137. extern struct icmplink Icmplink[];
  138.  
  139. /* In icmp.c: */
  140. void icmp_input __ARGS((struct iface *iface,struct ip *ip,struct mbuf *bp,
  141.     int rxbroadcast));
  142. int icmp_output __ARGS((struct ip *ip,struct mbuf *data,char type,char code,
  143.     union icmp_args *args));
  144.  
  145. /* In icmpcmd.c: */
  146. void echo_proc __ARGS((int32 source,int32 dest,struct icmp *icmp,struct mbuf *bp));
  147. int pingem __ARGS((int s,int32 target,int16 seq,int16 id,int16 len));
  148.  
  149. /* In icmphdr.c: */
  150. struct mbuf *htonicmp __ARGS((struct icmp *icmp,struct mbuf *data));
  151. int ntohicmp __ARGS((struct icmp *icmp,struct mbuf **bpp));
  152.  
  153. #endif    /* _ICMP_H */
  154.